package com.landun.market.web.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.landun.market.pojo.Constants;
import lombok.Data;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @author jiang.chuan
 * @date 2018-04-05
 */
@Data
public abstract class BaseVO<VO> {
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private List<VO> children;

    @JsonFormat(pattern = Constants.DATE_TIME_FORMAT, locale = "zh", timezone = "GMT+8")
    private Date createdTime;

    @JsonFormat(pattern = Constants.DATE_TIME_FORMAT, locale = "zh", timezone = "GMT+8")
    private Date updatedTime;

    public void addChild(VO child) {
        if (null == this.children) {
            this.children = new ArrayList<>();
        }
        this.children.add(child);
    }
}